home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr53
/
pctv4n_1.zip
/
STATUS.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-10
|
3KB
|
101 lines
// status.cpp -- TStatusBar class implementation by Tom Swan
#include <owl.h>
#pragma hdrstop
#include "status.h"
// Construct status bar object
TStatusBar::TStatusBar(PTWindowsObject AParent)
: currentID(0), TWindow(AParent, NULL)
{
Attr.Style = WS_CHILD | WS_VISIBLE | WS_BORDER;
SetFlags(WB_MDICHILD, FALSE);
Attr.X = Attr.Y = Attr.W = Attr.H = 0;
}
// Perform initializations requiring a window handle
void TStatusBar::SetupWindow()
{
TEXTMETRIC tm; // Text "metrics" (i.e. specifications)
TWindow::SetupWindow();
// Calculate child height
HDC hDC = GetDC(HWindow);
GetTextMetrics(hDC, &tm);
ReleaseDC(HWindow, hDC);
childHeight = tm.tmHeight + (tm.tmHeight / 3);
// Initialize popup menu handles
HMENU hmenu = GetMenu(Parent->HWindow);
hmenuSystem = GetSystemMenu(Parent->HWindow, 0);
hmenuFile = GetSubMenu(hmenu, 0);
hmenuFont = GetSubMenu(hmenu, 1);
hmenuWindow = GetSubMenu(hmenu, 2);
}
// Modify status bar's registered class
void TStatusBar::GetWindowClass(WNDCLASS &AWndClass)
{
TWindow::GetWindowClass(AWndClass);
AWndClass.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
}
// Adjust size and postion of status bar
void TStatusBar::AdjustSize(WORD parentWidth, WORD parentHeight)
{
int x = 0, y = parentHeight - childHeight + 1;
MoveWindow(HWindow, x, y, parentWidth, childHeight, TRUE);
}
// Remove status bar's area from client rectangle
void TStatusBar::UMCalcParentClientRect(RTMessage Msg)
{
((RECT *)Msg.LParam)->bottom -= childHeight;
}
// Show on-line message according to menu selection
void TStatusBar::WMMenuSelect(RTMessage msg)
{
WORD wIDItem = msg.WParam; // ID or popup menu handle
WORD fwMenu = msg.LP.Lo; // Message flags
HMENU hmenu = (HMENU)msg.LP.Hi; // NULL or system menu handle
int resourceID = 0;
int menuClosing = ((fwMenu == 0xffff) && (hmenu == 0));
if (fwMenu & MF_POPUP) {
if ((HMENU)wIDItem == hmenuSystem) resourceID = 1;
else if ((HMENU)wIDItem == hmenuFile) resourceID = 2;
else if ((HMENU)wIDItem == hmenuFont) resourceID = 3;
else if ((HMENU)wIDItem == hmenuWindow) resourceID = 4;
} else if (!menuClosing)
resourceID = wIDItem;
DisplayString(resourceID);
}
// Display string in child window
void TStatusBar::DisplayString(int resourceID)
{
RECT r;
char s[128];
s[0] = 0;
if (resourceID != 0)
LoadString(GetApplication()->hInstance,
resourceID, s, sizeof(s));
currentID = resourceID; // Save ID for Paint()
// Draw background and "chiseled steel" border
GetClientRect(HWindow, &r);
HDC hDC = GetDC(HWindow);
OffsetRect(&r, 1, 1);
FillRect(hDC, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH));
FrameRect(hDC, &r, (HBRUSH)GetStockObject(DKGRAY_BRUSH));
OffsetRect(&r, -1, -1);
FrameRect(hDC, &r, (HBRUSH)GetStockObject(WHITE_BRUSH));
// Draw text in child status-bar window
SetBkMode(hDC, TRANSPARENT);
ExtTextOut(hDC, 4, 0, ETO_CLIPPED, &r, s, lstrlen(s), NULL);
ReleaseDC(HWindow, hDC);
}
void TStatusBar::Paint(HDC, PAINTSTRUCT &)
{
DisplayString(currentID);
}